import {
    request,
    cityRequest,
} from '../network'
import configLastApiUrl from '../config'
// 根据typeRequest 来获取不用参数的请求
function getCurrentTypeDayData(loc, typeRequest, currentType, currentLang) {
    let newUrl = '';
    switch (typeRequest) {
        case 'now':
            newUrl = configLastApiUrl.curr_day;
            break;
        case '7d':
            newUrl = configLastApiUrl.seven_day;
            break;
        case 'life':
            newUrl = configLastApiUrl.life_index;
            break;
        case 'warning':
            newUrl = configLastApiUrl.weatherWarning;
            break;
        case '24h':
            newUrl = configLastApiUrl.hours_data;
            break;
        case 'air':
            newUrl = configLastApiUrl.current_air;
            break;
    }
    return request({
        url: newUrl,
        params: {
            location: loc,
            type: currentType,
            lang: currentLang
        },
    })
}
// 城市地址
function getCity(loc) {
    return cityRequest({
        url: configLastApiUrl.city_address,
        params: {
            location: loc,
        }
    })
}

export {
    getCurrentTypeDayData,
    getCity,
}